﻿namespace JanusTestProject
{
    using Rsdn.Janus;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System;
    using System.Text.RegularExpressions;

    /// <summary>
    ///This is a test class for UrlHelperTest and is intended
    ///to contain all UrlHelperTest Unit Tests
    ///http://www.ietf.org/rfc/rfc1808.txt
    ///</summary>
    [TestClass()]
    public class UrlHelperTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        /// <summary>
        ///A test for GetHostname
        ///</summary>
        [TestMethod()]
        public void GetHostnameTest()
        {
            Match urlMatch = null; // 
            string expected = string.Empty; 
            string actual;
            actual = UrlHelper.GetHostname(urlMatch);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for IsDomainPresent
        ///</summary>
        //[TestMethod()]
        //public void IsDomainPresentTest()
        //{
        //    Match urlMatch = null; //  Initialize to an appropriate value
        //    string urlAddress = string.Empty; //  Initialize to an appropriate value
        //    bool expected = false; //  Initialize to an appropriate value
        //    bool actual;
        //    actual = UrlHelper.IsDomainPresent(urlMatch, urlAddress);
        //    Assert.AreEqual(expected, actual);
        //}

        /// <summary>
        ///A test for IsDomainPresent
        ///</summary>
        [TestMethod()]
        public void IsDomainPresentTest1()
        {
            string urlAddress = @"http://rsdn.ru/?forum/nemerle/4269435.aspx";
            bool expected = true;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_01()
        {
            string urlAddress = @"http://rsdn.ru/forum/nemerle/4269435.1.aspx";
            bool expected = true;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_02()
        {
            string urlAddress = @"http://forum/nemerle/4269435.1.aspx";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_03()
        {
            string urlAddress = @"forum/nemerle/4269435.1.aspx";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_04()
        {
            string urlAddress = @"rsdn.ru/forum/nemerle/4269435.1.aspx";
            bool expected = true;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_05()
        {
            string urlAddress = @"rsdn.ru";
            bool expected = true;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_06()
        {
            string urlAddress = @"";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void IsDomainPresentTest1_07()
        {
            string urlAddress = null;
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_08()
        {
            //../../../g    = <URL:http://a/../g>
            // ../../../../g = <URL:http://a/../../g>

            string urlAddress = @"//../../../g";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_09()
        {
            //../../../g    = <URL:http://a/../g>
            // ../../../../g = <URL:http://a/../../g>

            string urlAddress = @"//../../../../g";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_10()
        {
            // /./g          = <URL:http://a/./g>
            // /../g         = <URL:http://a/../g>
            // g.            = <URL:http://a/b/c/g.>
            // .g            = <URL:http://a/b/c/.g>
            // g..           = <URL:http://a/b/c/g..>
            // ..g           = <URL:http://a/b/c/..g>

            string urlAddress = @"/./g";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_11()
        {
            // /./g          = <URL:http://a/./g>
            // /../g         = <URL:http://a/../g>
            // g.            = <URL:http://a/b/c/g.>
            // .g            = <URL:http://a/b/c/.g>
            // g..           = <URL:http://a/b/c/g..>
            // ..g           = <URL:http://a/b/c/..g>

            string urlAddress = @"/../g";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_12()
        {
            // /./g          = <URL:http://a/./g>
            // /../g         = <URL:http://a/../g>
            // g.            = <URL:http://a/b/c/g.>
            // .g            = <URL:http://a/b/c/.g>
            // g..           = <URL:http://a/b/c/g..>
            // ..g           = <URL:http://a/b/c/..g>

            string urlAddress = @"g.";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_13()
        {
            // /./g          = <URL:http://a/./g>
            // /../g         = <URL:http://a/../g>
            // g.            = <URL:http://a/b/c/g.>
            // .g            = <URL:http://a/b/c/.g>
            // g..           = <URL:http://a/b/c/g..>
            // ..g           = <URL:http://a/b/c/..g>

            string urlAddress = @".g";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_14()
        {
            // /./g          = <URL:http://a/./g>
            // /../g         = <URL:http://a/../g>
            // g.            = <URL:http://a/b/c/g.>
            // .g            = <URL:http://a/b/c/.g>
            // g..           = <URL:http://a/b/c/g..>
            // ..g           = <URL:http://a/b/c/..g>

            string urlAddress = @"g..";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsDomainPresentTest1_15()
        {
            // /./g          = <URL:http://a/./g>
            // /../g         = <URL:http://a/../g>
            // g.            = <URL:http://a/b/c/g.>
            // .g            = <URL:http://a/b/c/.g>
            // g..           = <URL:http://a/b/c/g..>
            // ..g           = <URL:http://a/b/c/..g>

            string urlAddress = @"..g";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void IsDomainPresentTest1_16()
        {
            // ./../g        = <URL:http://a/b/g>
            // ./g/.         = <URL:http://a/b/c/g/>
            // g/./h         = <URL:http://a/b/c/g/h>
            // g/../h        = <URL:http://a/b/c/h>

            string urlAddress = @"./../g";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void IsDomainPresentTest1_17()
        {
            // ./../g        = <URL:http://a/b/g>
            // ./g/.         = <URL:http://a/b/c/g/>
            // g/./h         = <URL:http://a/b/c/g/h>
            // g/../h        = <URL:http://a/b/c/h>

            string urlAddress = @"./g/.";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void IsDomainPresentTest1_18()
        {
            // ./../g        = <URL:http://a/b/g>
            // ./g/.         = <URL:http://a/b/c/g/>
            // g/./h         = <URL:http://a/b/c/g/h>
            // g/../h        = <URL:http://a/b/c/h>

            string urlAddress = @"g/./h";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void IsDomainPresentTest1_19()
        {
            // ./../g        = <URL:http://a/b/g>
            // ./g/.         = <URL:http://a/b/c/g/>
            // g/./h         = <URL:http://a/b/c/g/h>
            // g/../h        = <URL:http://a/b/c/h>

            string urlAddress = @"g/../h";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void IsDomainPresentTest1_20()
        {
            // http:g        = <URL:http:g>
            // http:         = <URL:http:>

            string urlAddress = @"http:g";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void IsDomainPresentTest1_21()
        {
            // http:g        = <URL:http:g>
            // http:         = <URL:http:>

            string urlAddress = @"http:";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void IsDomainPresentTest1_22()
        {
            string urlAddress = @"./this:that";
            bool expected = false;

            bool actual = UrlHelper.IsDomainPresent(urlAddress);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for IsSchemePresent
        ///</summary>
        [TestMethod()]
        public void IsSchemePresentTest()
        {
            string url = string.Empty; 
            bool expected = false; 
            bool actual;
            actual = UrlHelper.IsSchemePresent(url);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for IsSchemePresent
        ///</summary>
        [TestMethod()]
        public void IsSchemePresentTest1()
        {
            Match urlMatch = null; 
            bool expected = false; 
            bool actual;
            actual = UrlHelper.IsSchemePresent(urlMatch);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for IsValidUrl
        ///</summary>
        [TestMethod()]
        public void IsValidUrlTest()
        {
            string testUri = string.Empty; 
            bool expected = false; 
            bool actual;
            actual = UrlHelper.IsValidUrl(testUri);
            Assert.AreEqual(expected, actual);
        }
        //[url]http://folding.stanford.edu[/url]

        /// <summary>
        ///A test for AddUrlScheme
        ///</summary>
        [TestMethod()]
        public void AddUrlSchemeTest()
        {
            string sourceUri = string.Empty;
            string expected = string.Empty; 
            string actual = UrlHelper.AddUrlScheme(sourceUri);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void AddUrlSchemeTest01()
        {
            string sourceUri = null;
            string expected = null;
            string actual = UrlHelper.AddUrlScheme(sourceUri);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void AddUrlSchemeTest02()
        {
            string sourceUri = "h";
            string expected = "http://h";
            string actual = UrlHelper.AddUrlScheme(sourceUri);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void AddUrlSchemeTest03()
        {
            string sourceUri = "http";
            string expected = "http://http";
            string actual = UrlHelper.AddUrlScheme(sourceUri);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void AddUrlSchemeTest04()
        {
            string sourceUri = "http:";
            string expected = "http:";
            string actual = UrlHelper.AddUrlScheme(sourceUri);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void AddUrlSchemeTest05()
        {
            string sourceUri = "http://";
            string expected = "http://";
            string actual = UrlHelper.AddUrlScheme(sourceUri);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void AddUrlSchemeTest06()
        {
            string sourceUri = "//a";
            string expected = "http://a";
            string actual = UrlHelper.AddUrlScheme(sourceUri);
            Assert.AreEqual(expected, actual);
        }

    }
}
